package com.controller;

import com.bean.Customer;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class JsonController {

    @RequestMapping("testJson")
    public String JsonMethod() {
        Customer cu=new Customer();
        cu.setId(11);
        cu.setUname("admin5");
        cu.setPassword("5555");
        cu.setEmail("111@163.com");
        cu.setAge(19);

        ObjectMapper obj = new ObjectMapper();

        try {
            return obj.writeValueAsString(cu);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        return null;


    }
}
